var test = 4

$(function () {
  $('#menubtn').click(function(){
    $("#navBar").css({
      backgroundColor:"white",
    })
  })
})

// function mHttp() {
//   var job_name = $('#job_name').val()
//   var f_time = $('#f_time').val()
//   var total_cost = $('#total_cost').val()
//   var job_time = $('#job_time').val()
//   var job_prosen = $('#job_prosen').val()
//   var job_consume = $('#job_consume').val()
//   var job_con = $('#job_con').val()
//   var url =  host + '/totalfinance?job_name=' + job_name+ '&f_time=' + f_time + '&total_cost=' + total_cost + '&job_time=' + job_time + '&job_prosen=' + job_prosen  + '&job_consume=' + job_consume + '&job_con=' + job_con 
//   let httpRequest = new XMLHttpRequest();//第一步：创建需要的对象
//   httpRequest.open('POST', url, true); //第二步：打开连接/***发送json格式文件必须设置请求头 ；如下 - */
//   // httpRequest.open('GET', url, true); //第二步：打开连接/***发送json格式文件必须设置请求头 ；如下 - */
//   httpRequest.setRequestHeader("Access-Control-Allow-Credentials", true);//设置请求头 注：post方式必须设置请求头（在建立连接后设置请求头）var obj = { name: 'zhansgan', age: 18 };
//   httpRequest.setRequestHeader("Access-Control-Allow-Origin", "*");
//   httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
//   var data = 'job_name=' + job_name+ '&f_time=' + f_time + '&total_cost=' + total_cost + '&job_time=' + job_time + '&job_prosen=' + job_prosen  + '&job_consume=' + job_consume + '&job_con=' + job_con 
//   httpRequest.send(data);//发送请求 将json写入send中
//   /**
//    * 获取数据后的处理程序
//    */
//   httpRequest.onreadystatechange = function () {//请求后的回调接口，可将请求成功后要执行的程序写在其中
//     if (httpRequest.readyState == 4 && httpRequest.status == 200) {//验证请求是否发送成功
//       var json = JSON.parse(httpRequest.responseText);//获取到服务端返回的数据
//       console.log(json);
//       if(json['message'] == '提交成功'){
//         alert('提交成功！')
//       }else{
//         alert('提交失败！')
//       }
//   }
//   };
// }

function mHttp() {
  var job_name = $('#job_name').val()
  var f_time = $('#f_time').val()
  var total_cost = $('#total_cost').val()
  var job_time = $('#job_time').val()
  var job_prosen = $('#job_prosen').val()
  var job_consume = $('#job_consume').val()
  var job_con = $('#job_con')[0].files[0]

  var formData = new FormData()

  formData.append('job_name',job_name)
  formData.append('f_time',f_time)
  formData.append('total_cost',total_cost)
  formData.append('job_time',job_time)
  formData.append('job_prosen',job_prosen)
  formData.append('job_consume',job_consume)
  formData.append('job_con',job_con)

  $.ajax({
    url: host + '/totalfinance',
    type:'POST',
    data:formData,
    cache:false,
    processData: false, // 告诉jQuery不要去处理发送的数据
    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
    success:function(data) {
      console.log(data);
    },
    error: function(data) {    
      console.log(data)    
    } 
  })

}